package com.zy.socket.chat2;

import java.io.DataInputStream;
import java.io.IOException;
import java.net.Socket;

/**
 * @Author Gong
 * @Description
 * @dATE 2021/12/19 16:09
 **/
public class MyClientReceiveThread extends Thread{
    private Socket client;
    MyClientReceiveThread(Socket client){
        this.client = client;
    }
    @Override
    public void run() {
        DataInputStream dis = null;

        System.out.println("来自客户端"+client.getRemoteSocketAddress()+"的链接！");
        try {
           dis= new DataInputStream(client.getInputStream());

           while (true){
               String str = dis.readUTF();
               System.out.println("收到来自服务端的响应:"+str);
           }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
